package com.njit;

/**
 * Created by ospip on 2017/11/29.
 * Copyright (c) 2017 LLAP. All rights reserved.
 */
import java.util.*;
import javax.swing.table.*;

public class MyTableModel extends DefaultTableModel {
    /**
     *
     */
    private static final long serialVersionUID = 2383395442983641849L;
    private ArrayList<Integer> editedIndex = new ArrayList<>();

    public MyTableModel() {
        super();
    }
    public boolean isCellEditable(int row, int column) {
        if (column == 0) return false;
        return true;
    }
    public void setValueAt(Object aValue, int row, int column) {
        super.setValueAt(aValue, row, column);
        int i, count = editedIndex.size();
        if (count == 0) editedIndex.add(row);
        else {
            for (i = 0; i < count; i++) {
                if (editedIndex.get(i) > row) {
                    editedIndex.add(i + 1, row);
                    break;
                }
            }
            if (i >= count) editedIndex.add(row);
        }
    }

    public ArrayList<Integer> getEditedIndex() {
        return editedIndex;
    }
    public static void main(String[] args) {

    }

}
